<template>
  <view class="v-badge-container">
    <slot />
    <view
      v-if="value && value !== '0'"
      class="v-badge"
    >
      {{ value.length > 3 ? '99+' : value }}
    </view>
  </view>
</template>

<script setup lang="ts">
defineProps<{
  value?: string;
}>();
</script>

<style lang="scss" scoped>
.v-badge-container {
  position: relative;
  height: fit-content;
  width: fit-content;
}
.v-badge {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(50%, -50%);
  color: white;
  font-size: 22rpx;
  background-color: #ff2f3b;
  min-width: 32rpx;
  line-height: 32rpx;
  height: 32rpx;
  border-radius: 32rpx;
  box-sizing: border-box;
  padding: 0 10rpx;
  text-align: center;
}
</style>
